﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;

namespace WXYW
{
    public partial class ExportBasicInformation : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindDropDown();
            }
        }

        private void BindDropDown()
        {
            ServiceStationService service = new ServiceStationService();
            ssDropDownList.DataSource = service.GetAllWithSelectOne();
            ssDropDownList.DataTextField = "Name";
            ssDropDownList.DataValueField = "ID";
            ssDropDownList.DataBind();

            accDropDownList.DataSource = service.GetAllWithSelectOne();
            accDropDownList.DataTextField = "Name";
            accDropDownList.DataValueField = "ID";
            accDropDownList.DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            ExportService service = new ExportService();
            GridView gv = new GridView();
            gv.DataSource = service.ExportProductInformation();
            gv.DataBind();

            ExportExcel.ExportExcelFromGridView(gv, "产品信息");
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            ExportService service = new ExportService();
            GridView gv = new GridView();
            gv.DataSource = service.ExprotProvider();
            gv.DataBind();

            ExportExcel.ExportExcelFromGridView(gv, "代理商信息");
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            ExportService service = new ExportService();
            GridView gv = new GridView();
            gv.DataSource = service.ExportClient();
            gv.DataBind();

            ExportExcel.ExportExcelFromGridView(gv, "客户资料");
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            ExportService service = new ExportService();
            GridView gv = new GridView();
            gv.DataSource = service.ExportSparePart(ssDropDownList.SelectedValue);
            gv.DataBind();

            ExportExcel.ExportExcelFromGridView(gv, "备件管理");
        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            ExportService service = new ExportService();
            GridView gv = new GridView();
            gv.DataSource = service.ExportAccessory(accDropDownList.SelectedValue);
            gv.DataBind();

            ExportExcel.ExportExcelFromGridView(gv, "元器件管理");
        }
    }
}
